package org.six11.ss.client;

import java.util.ArrayList;
import java.util.List;

import org.jdom.Element;
import org.six11.ss.shared.Message;
import org.six11.util.adt.MultiState;

/**
 * 
 *
 * @author Gabe Johnson <johnsogg@cmu.edu>
 */
public class RoomMembershipMessageHandler extends AWTMessageHandler {

  /**
   * @param state
   */
  public RoomMembershipMessageHandler(MultiState state) {
    super(state);
  }

  /**
   * 
   */
  @Override
  public void handleAWT(Message msg) {
    List<Element> players = msg.getRoot().getChildren("player");
    TextConsole console = getConsole();
    List<String> playerStrings = new ArrayList<String>();
    for (Element elm : players) {
      playerStrings.add(elm.getAttributeValue("name"));
    }
    console.addPlayerList(playerStrings);    
  }

}
